<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix='fmt' uri="http://java.sun.com/jsp/jstl/fmt" %>
<% 
response.setHeader("Pragma","No-cache"); 
response.setHeader("Cache-Control","no-cache"); 
response.setDateHeader("Expires", 0); 
%> 
<link rel="stylesheet" href="static/plugs/editor.md/css/editormd.min.css" />
<div style="padding: 10px;">
	<form id="addfilesuploadform" action="${pageContext.request.contextPath}/back/files/addfilesupload" enctype="multipart/form-data" method="post">
		<input id="addfilesuploadinput" onchange="uploadfile();" type="file" name="file" style="display: none;"/>
	</form>
	<form id="singleAddForm" class="layui-form layui-form-pane" action="${pageContext.request.contextPath}/back/single/addsingle">
	    <input name="status" value="2" style="display: none;">
		<div class="layui-form-item ">
		    <label class="layui-form-label">页面标题</label>
		    <div class="layui-input-block">
		      <input type="text" name="title" lay-verify="required" autocomplete="off" maxlength="100" placeholder="请输页面标题" class="layui-input">
		    </div>
		</div>
		<div class="layui-form-item ">
		    <label class="layui-form-label">页面图标</label>
		    <div class="layui-input-block">
		      <input type="text" name="summary" lay-verify="required" autocomplete="off" maxlength="200" placeholder="请输页面图标" class="layui-input">
		    </div>
		</div>
		<div class="layui-form-item ">
		    <label class="layui-form-label">显示类型</label>
		    <div class="layui-input-block">
		    	<select lay-filter="type" name="type">
			        <option value="100">编辑页面</option>
			        <option value="101">url(跳转)</option>
			        <option value="102">url(新窗口)</option>
			    </select>
		    </div>
		</div>
		<div class="showtypechangeurl layui-form-item " style="display: none;">
		    <label class="layui-form-label">url</label>
		    <div class="layui-input-block">
		      <input type="text" name="url" autocomplete="off" maxlength="200" placeholder="请输url" class="layui-input">
		    </div>
		</div>
		<div class="showtypechange layui-form-item ">
		    <label class="layui-form-label">页面标识</label>
		    <div class="layui-input-block">
		      <input type="text" name="password" autocomplete="off" maxlength="50" placeholder="请输页面标识" class="layui-input">
		    </div>
		</div>
		<div class="showtypechange layui-form-item layui-form-text">
		    <label class="layui-form-label">
		    	头部图片&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
		    	<a onclick="$('#addfilesuploadinput').click();" class="layui-btn layui-btn-normal layui-btn-radius layui-btn-mini"><i class="layui-icon"></i>&nbsp&nbsp上传</a>
		      	<a onclick="removetagsnew();" class="layui-btn  layui-btn-primary layui-btn-radius layui-btn-mini">选择已有图片</a>
		      	<input id="topimginput"  name="topimg"  style="display:none;"/>
		      	<script type="text/javascript">
		        //上传文件
			  	function uploadfile(){
			  		$("#addfilesuploadform").ajaxSubmit({
				        type: 'post', // 提交方式 get/post
				        success: function(data) { // data 保存提交后返回的数据，一般为 json 数据
				        	var json = eval(data);
				        	console.log(json);
				        	if(json.code=="0"){
				                layer.msg('添加成功！');
				                $("#topimgshow").html("<img style='height:100px;' src='"+json.data.src+"'/>");
				                $("#topimginput").val(json.data.src);
				        	}else{
				                layer.msg('添加失败！');
				        	}
				        }
				    });
			  	}
		      	</script>
		    </label>
		    <div id="topimgshow" class="layui-input-block" style="height:100px;border: 1px solid #e6e6e6;">
		    </div>
		</div>
		<div class="layui-form-item layui-form-text" style="">
		    <label class="layui-form-label">内容</label>
		    <div class="layui-input-block">
		    	<div id="articlecontenteditormd">
                	<textarea name="content" id="articlecontent" style="display:none;"></textarea>
	            </div>
		    </div>
		</div>
		<div class="layui-form-item" align="center">
		    <button class="layui-btn"  lay-submit="" lay-filter="singleAddSubmit" style="width:120px;">提交</button>
		    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
		</div>
	</form>
	<script src="${pageContext.request.contextPath}/static/js/back/single/singleAddPage.js"></script>
	<script src="static/plugs/editor.md/editormd.min.js"></script>
    <script type="text/javascript">
		var articlecontenteditormd;
        $(function() {
            articlecontenteditormd = editormd({
                id      : "articlecontenteditormd",
                width   : "100%",
                height  : 640,
                emoji : true,
                saveHTMLToTextarea : true,
                imageUpload : true,
                imageFormats : ["jpg", "jpeg", "gif", "png", "bmp"],
                imageUploadURL : basePath+"back/files/editormdimagefile",
                path    : "static/plugs/editor.md/lib/"
            });
        });
    </script>
</div>
    